home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16988 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: undergrad.math.uwaterloo.ca!clgonsal
  3. From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
  4. Subject: Re: Why don't you use garbage collection
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <DprnAs.C0@undergrad.math.uwaterloo.ca>
  7. Date: Fri, 12 Apr 1996 20:23:16 GMT
  8. References: <4kiai0$mjd@dfw-ixnews8.ix.netcom.com> <316D291F.465D@sto.fdata.se>
  9. Nntp-Posting-Host: lhopital.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <316D291F.465D@sto.fdata.se>,
  13. Niklas Mellin  <niklas.mellin@sto.fdata.se> wrote:
  14. >Giuliano Carlini wrote:
  15. >> In my experience, most C/C++ programmers either don't know what garbage
  16. >> collection is, or don't know that it can be used with C/C++. After all,
  17. >> no major C/C++ compiler includes a garbage collector. At least, as far
  18. >> as I know. I hope I'm wrong, and that someone can correct me. But even
  19. >> after, I tell them what it is, and that it can be used with C++, almost
  20. >> everyone still rejects it.
  21. >
  22. >No major C/C++ compiler includes a garbage collector, because it is not a
  23. >part of the C++ language. If you want a garbage collector you should go out
  24. >looking for a class library that implements it, not for a compiler. A C++
  25. >compiler that do garbage collection when you forget delete wouldn't be a
  26. >C++ compiler.
  27.  
  28. There is nothing in the C++ language definition that says an implementation
  29. cannot use garbage collection. There was some talk in at least one of the
  30. books by Bjarne about GC. I seem to remember something to the effect of GC
  31. could exist in an implementation, but there are a few restrictions. For one
  32. thing, the destructor of a collected object never gets called. The
  33. rationale is that GC is a simulation of infinite memory, and so collected
  34. objects can't do anything when they get collected, since in an infinite 
  35. memory system these objects aren't deleted. This means, with such a
  36. compiler, you'd probably want some other way of "finalizing" objects. This
  37. would probably have to be handled by a compiler extension. 
  38.  
  39. -- 
  40.         Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
  41.                    Computer Science, University of Waterloo
  42.                http://www.undergrad.math.uwaterloo.ca/~clgonsal/
  43.                    http://www.csclub.uwaterloo.ca/~clgonsal/
  44.